<!doctype html>
<html><head>
<meta charset="utf-8">
<title>定制应用采集页面</title>
<link rel="stylesheet" type="text/css" href="resources/css/pagination.css">
<link rel="stylesheet" type="text/css" href="resources/css/despoke.css">
<script src="resources/js/jquery-1.7.2.min.js"></script>
<script src="resources/js/jquery.pagination.js"></script>
<script src="resources/js/Calendar4.js"></script>
<script src="resources/js/common.js"></script>
<script src="resources/js/despoke.js"></script>

<script type="text/javascript">
var logoid="#smallmaplink",ostype="Android",listostype="all"
var curp=1,pagesize=3,pcount=0;
$(document).ready(function(e) {
	
	//初始化分类列表
	inittypes(ostype);
	//读取所有定制应用
   $("input[type='radio']").change(function(){
	   $("#category").children().remove();
	   ostype=$(this).val();
	  	inittypes(ostype)
	  });
	
	$("#addbtn").click(function(){
		//组装必填项参数数组
		var params=getParamsArray();
		if(checkparam(params) && checksize())
		{
			
			$(this).css("color","#999").css("font-size","13px").text("正在执行.....");
			//这里是选填参数
			params.push($("#description"));
			params.push($("#sign"));
			params.push($("#downloadnumber"));
			//组装json参数
			var jsonstr=strToJsonStr(params);
			//alert(jsonstr);
			//var jsonobj=eval('(' + jsonstr + ')');
			//document.write(jsonstr);
			var url2=jsonserver+"appstore/addapp/"+jsonstr;
			setTimeout(function(){
					$.getJSON(url2+".jsonp?callback=?",{},function(data){
						var colorstr="red";
						if(data.status=="00000")
						{
							colorstr="#096";
							initlist(listostype,curp,pagesize);
							$("input[type=text]").val("");
							$("textarea").val("");
						}
						$("#showmsg").css("color",colorstr).text(data.msg).fadeIn(700);
						
						$("#addbtn").html("<button>确认添加</button>");

					});
			},1500);
			
		}
		else
		{
			$("#showmsg").css("color","red").text("请检查必填项是否填写完全").fadeIn(700);
		}
		setTimeout(function(){
			$("#showmsg").fadeOut();
		},3000);
	});
	$("#packagesize").blur(function(){
		checksize();
	});
	$("#packagesize").focus(function(){
		$("#formaterror").text("");
	});
	$("#ostype").change(function(){
		//alert($(this).val());
		ostype=$(this).val();
		initlist(ostype,curp,pagesize);
	});
	
	
	
$("#updatebtn").click(function(){
		//alert($(":radio[checked=checked]").val());
		//alert($("input[name='platform']").val());
		var params=getParamsArray();
		if(checkparam(params) && checksize())
		{
			$(this).css("color","#999").css("font-size","13px").text("正在执行.....");
			//这里是选填参数
			params.push($("#description"));
			params.push($("#sign"));
			//组装json参数
			var jsonstr1=strToJsonStr(params);
			 update(jsonstr1);
		}
		else
		{
			$("#showmsg").css("color","red").text("请检查必填项是否填写完全").fadeIn(700);
		}
		setTimeout(function(){
			$("#showmsg").fadeOut();
		},3000);
	});
	
	getcount();
	
});

function getcount()
{
	var c=0;
	var counturl=jsonserver+"appstore/despokecount";
	$.getJSON(counturl+".jsonp?callback=?",{},function(data){
		c=parseInt(data.count);
		$("#Pagination").pagination(c, {
			callback: PageCallback, //PageCallback() 为翻页调用次函数。
			prev_text: "<<上一页",
			next_text: "下一页>>",
			items_per_page:pagesize,
			num_edge_entries: 6, //两侧首尾分页条目数
			num_display_entries: 9, //连续分页主体部分分页条目数
			current_page: curp-1, //当前页索引
		});
		function PageCallback(index, jq) {
			//alert("ostype:"+ostype+",curp:"+index+",pagesize:"+pagesize);
			initlist(listostype,index+1,pagesize);
		}
	});

}


</script>

</head>

<body>
<div id="showmsg"></div>
<div id="detail">
<table width="98%">
 <tr>
    <td colspan="4" style="font-size:18px; font-weight:bold;"><span>注:</span>带<span>*</span>的为必填项!</td>
  </tr>
  <tr>
    <td width="15%">ID</td>
    <td width="35%"><input type="text" id="appid"/> <span>*</span></td>
    <td width="15%">名称</td>
    <td width="35%"><input type="text" id="title"/><span>*</span></td>
  </tr>
  <tr>
   
    <td>平台</td>
    <td colspan="4">安卓<input type="radio"  name="platform" value="Android"/> 苹果<input type="radio" name="platform" value="Apple"/>　　　　　　　　　　　　　所属分类　　　　<select id="category"></select>　　　　　　　　　　下载次数　　　<input type="text" id="downloadnumber"/></td>
     <td></td>
    <td></td>
  </tr>
  <tr>
    <td>版本</td>
    <td><input type="text" id="version"/><span>*</span></td>
    <td>发布时间</td>
    <td><input type="date" id="releasedate" readonly/>
    <button onclick="MyCalendar.SetDate(this,document.getElementById('releasedate'))">选择</button><span>*</span></td>
  </tr>
  <tr>
    <td>描述</td>
    <td><textarea rows="30" cols="25" id="description" style="height:30px;"></textarea></td>
    <td>资费类型</td>
    <td>
    <select id="fee">
    	<option value="1">完全免费</option>
        <option value="4">限时免费</option>
        <option value="5">收费应用</option>
    </select>
   	</td>
  </tr>
  <tr>
    <td>大小</td>
    <td><input type="text" id="packagesize"/>MB<span>*</span><span id="formaterror"></span></td>
    <td>标识</td>
    <td><select id="sign">
    	<option value="1">启用</option>
        <option value="0">废弃</option>
    </select></td>
  </tr>
  <tr>
    <td>下载地址</td>
    <td><input type="text" id="packagelink"/><span>*</span></td>
    <td>图标链接地址</td>
    <td >
    	<div id="local" style="display:none;" ><input type="file" id="locallogo"/><span>*</span>　　　　<button>上传</button><button onClick="showlogo('#net','#local');" >使用网络图片</button></div>
        <div id="net" ><input type="text" id="smallmaplink"/><span>*</span><!--<button onClick="showlogo('#local','#net');">上传本地图片</button>--></div>
    </td>
  </tr>
  <tr>
    <td colspan="4" align="center">
    <a id="addbtn" style="cursor:pointer;"><button>确认添加</button></a>　
    <a id="updatebtn" style="cursor:pointer; display:none;"><button>确认修改</button></a>
    <a id="back"><button>返回</button></a>
    </td>
  </tr>
</table>
<div>
<hr width="100%"/>
<div id="list">
<div style=" margin-left:60%;">
<div id="Pagination" class="pagination"></div>
平台类型:
<select id="ostype" >
	<option value="all" selected>全部</option>
	<option value="Android">安卓</option>
    <option value="Apple">苹果</option>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span onClick="initlist('all',1,2);" style=" cursor:pointer; color:#000; border:1px #000000 solid; font-size:13px;">刷新</span>
</div>

<table width="98%"  id="showdatas" cellpadding="0" cellspacing="0">
  <tr style="font-weight:bold; font-size:18px;">
    <td>ID</td>
    <td>名称</td>
    <td>平台</td>
    <td>分类</td>
    <td>版本</td>
    <td>发布时间</td>
    <td>描述</td>
    <td>资费类型</td>
    <td>大小</td>
    <td>标识</td>
    <td>下载次数</td>
    <td>下载地址</td>
    <td>图标链接地址</td>
    <td>操作</td>
   </tr>
</table>

</div>
</body>
</html>
